const api = {
  getByIdForCache: '/api/xmbz-order/orderGroupLink/open/getByIdForCache',
  // getSelfDelivery: '/api/xmbz-order/orderGroupLink/open/getSelfDelivery',
  getCurrencyLink: '/api/xmbz-order/orderGroupLink/open/getCurrencyLink',
  getisRange: '/api/xmbz-order/orderGroupLink/open/isRange',
  getGoodsListByName: '/api/xmbz-order/orderGroupLink/open/getGoodsListByName',
  getSelfDeliveryAddress: '/api/xmbz-order/orderGroupLink/open/getSelfDeliveryAddress',
  submitOrder: '/api/xmbz-order/orderGroupLink/open/submitOrder',
  getChannelByDeptId: '/api/xmbz-system/deptChannel/open/getChannelByDeptId',
  getOrderById: '/api/xmbz-order/orderGroupLink/open/getOrderById',
  getpreSubmitOrder: '/api/xmbz-order/orderGroupLink/open/preSubmitOrder',
  // upload: '/api/xmbz-goods/file/upload',
    upload: '/api/xmbz-goods/file/open/uploadBase64',
  getSelfDelivery:'/api/xmbz-order/orderGroupLink/open/getDeptList',
  getOrderList:'/api/xmbz-order/orderGroupLink/open/getOrderList',
  getCaptcha:'/api/xmbz-order/orderGroupLink/open/phoneCaptcha',
  // getCaptcha:'http://192.168.0.30:8107/orderGroupLink/open/phoneCaptcha',
  imgCaptcha:'/api/xmbz-order/orderGroupLink/open/imgCaptcha',
  verifyCaptcha:'/api/xmbz-order/orderGroupLink/open/verifyCaptcha',
  getInsideChannel:'/api/xmbz-order/orderGroupLink/open/getInsideChannel',
  getWxNumber:'/api/xmbz-order/orderGroupLink/open/getWxNumber',
  getAssistant: '/api/xmbz-order/orderGroupLink/open/getAssistant',

}

// export default api
import qs from 'qs'
// axios
import request from '@/utils/request'

// H5根据团购链接ID查询详情


export function getByIdForCache(params) {
  return request({
    url: api.getByIdForCache,
    method: 'get',
    params,
    hideloading: true // 隐藏 loading 组件
  })
}
export function getInsideChannel(params) {
  return request({
    url: api.getInsideChannel,
    method: 'get',
    params,
    hideloading: true // 隐藏 loading 组件
  })
}
// H5获取自提城市列表
export function getSelfDelivery(params) {
  return request({
    url: api.getSelfDelivery,
    method: 'get',
     params,
    hideloading: true // 隐藏 loading 组件
  })
}

export function getCurrencyLink(params) {
  return request({
    url: api.getCurrencyLink,
    method: 'get',
    data: qs.stringify(params),
    hideloading: true // 隐藏 loading 组件
  })
}
export function getisRange(params) {
  // H5根据经纬度查询地址是否在配送范围
  return request({
    url: api.getisRange,
    method: 'get',
    params,
    hideloading: true // 隐藏 loading 组件
  })
}
export function getGoodsListByName(params) {
  // H5根据经纬度查询地址是否在配送范围
  return request({
    url: api.getGoodsListByName,
    method: 'get',
    params,
    hideloading: true // 隐藏 loading 组件
  })
}
export function getSelfDeliveryAddress(params) {
  // 根据城市ID获取自提地址列表
  return request({
    url: api.getSelfDeliveryAddress,
    method: 'get',
    params,
    hideloading: true // 隐藏 loading 组件
  })
}
export function submitOrder(data) {
  // 根据城市ID获取自提地址列表
  return request({
    url: api.submitOrder,
    method: 'post',
    data,
    hideloading: true // 隐藏 loading 组件
  })
}
export function getChannelByDeptId(params) {
  // H5根据城市ID获取渠道列表
  return request({
    url: api.getChannelByDeptId,
    method: 'get',
    params,
    hideloading: true // 隐藏 loading 组件
  })
}


export function getOrderById(params) {
  // H5根据城市ID获取渠道列表
  return request({
    url: api.getOrderById,
    method: 'get',
    params,
    hideloading: true // 隐藏 loading 组件
  })
}
export function getpreSubmitOrder(data) {
  // H5预提交订单
  return request({
    url: api.getpreSubmitOrder,
    method: 'post',
    data,
    hideloading: true // 隐藏 loading 组件
  })
}
export function getCaptcha(params) {
  // H5预提交订单
  return request({
    url: api.getCaptcha,
    method: 'get',
    params,
    hideloading: true // 隐藏 loading 组件
  })
}
export function Getupload(data) {
  // H5预提交订单
  return request({
    url: api.upload,
    method: 'post',
    data,
    hideloading: true // 隐藏 loading 组件
  })
}
export function getOrderList(params) {
  // H5根据手机号查询团购列表
  return request({
    url: api.getOrderList,
    method: 'get',
    params,
    hideloading: true // 隐藏 loading 组件
  })
}
export function setCookie (c_name, value, expiredays) {

    var exdate = new Date();

    exdate.setDate(exdate.getDate() + expiredays);

    document.cookie = c_name + "=" + value + ((expiredays == null) ? "" : ";expires=" + exdate.toGMTString());

}
export function getCookie(name) {
	var arr, reg = new RegExp("(^| )" + name + "=([^;]*)(;|$)");
	if (arr = document.cookie.match(reg)){
   		return (arr[2]);
  	}else{
		return false
	}
 }
 export function delCookie (name) {
 	var exp = new Date();
 	exp.setTime(exp.getTime() - 1);
 	var cval = getCookie(name);
 	if (cval){
 	 	document.cookie = name + "=" + cval + ";expires=" + exp.toGMTString();
 	}
 }
export function imgCaptcha(params) {
  // H5获取图形验证码
  return request({
    url: api.imgCaptcha,
    method: 'get',
    params,
    hideloading: true // 隐藏 loading 组件
  })
}
export function verifyCaptcha(params) {
  // H5获取图形验证码
  return request({
    url: api.verifyCaptcha,
    method: 'get',
    params,
    hideloading: true // 隐藏 loading 组件
  })
}

export function getWxNumber(params) {
  // H5获取图形验证码
  return request({
    url: api.getWxNumber,
    method: 'get',
    params,
    hideloading: true // 隐藏 loading 组件
  })
}

// 输入提示
export const getAssistant = (query) => {
  return request({
    url: api.getAssistant,
    method: 'get',
    params: query
  })
}
